package com.yuantu.judiciary.dao;

import com.yuantu.judiciary.model.domain.DiscountCodeDO;
import com.yuantu.judiciary.model.domain.MembershipRankDO;
import com.yuantu.judiciary.model.form.DiscountCodeForm;
import com.yuantu.judiciary.model.form.DiscountCodeStatusForm;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * 动态信息
 *
 * @author syw
 * @since 2023-08-21
 **/
public interface IMembershipRankDao extends JpaRepository<MembershipRankDO, Long> {


    @Query("select mr from MembershipRankDO mr where mr.deleted = false ")
    List<MembershipRankDO> findInfos();

    @Query("select mr from MembershipRankDO mr where mr.deleted = false ")
    List<MembershipRankDO> findMembershipRankList();

    MembershipRankDO findInfoById(Long id);

    @Query("select m from MembershipRankDO m where :value >= m.lowScore and :value <= m.upScore")
    MembershipRankDO findMembershipRankDOByValue(Double value);

    MembershipRankDO findByIdAndDeletedFalse(Long id);

    @Modifying
    @Query("update MembershipRankDO set deleted = true where id = :membershipRankId and deleted = false ")
    void removeInfo(Long membershipRankId);
}
